<!-- budget 经费预算-->
<template>

  <div class="main budget administrativeAssets-container">
      <div class="table-name">
        <div class="table-name-content"><span class="table-name-text">经费预算</span></div>
      </div>
    <swiper :options="swiperOption" ref="mySwiper" @slideChangeTransitionStart="swiperChangeFunc($refs['mySwiper'])">
      <!-- slides -->
      <swiper-slide :class="{'swiper-no-swiping': $store.state.overHidden}">
        <div class="form-container">
          <dl class="form-card">
            <dt class="step-content">第一步：业务项目申报</dt>
            <dd class="form-list">
              <first-input-box h-kind="1" :h-check="subCheck" v-model="t_financeproinst.ACCEPT_NAME" h-placeholder="业务名称"></first-input-box>
            </dd>
            <dd class="form-list">
              <second-input-box name="申请人员" :content="t_financeproinst.STAFF_NAME"></second-input-box>
            </dd>
            <dd class="form-list">
              <second-input-box name="申请时间" :content="t_financeproinst.FINANCEPROINST_CREATEDATE"></second-input-box>
            </dd>
            <dd class="form-list">
              <first-input-box v-model="t_financeproinst.FINANCEPROINST_DESC" h-placeholder="备注说明"></first-input-box>
            </dd>
          </dl>
          <!-- <div class="banner-show">
            <img src="../../../assets/img/banner-01.jpg" alt="">
          </div> -->
          <input type="text" style="position:fixed;top:-100rem;left:-100rem;z-index:-1" @focus="$event.currentTarget.blur()">
        </div>
      </swiper-slide>
      <swiper-slide :class="{'swiper-no-swiping': $store.state.overHidden}">
        <div class="form-container" :class="$store.state.overHidden ? 'over-hidden' : ''">
          <dl class="form-card">
            <dt class="step-content">第二步：填写经费详情</dt>
        <dd class="form-list">
          <first-input-box h-kind="1" :h-check="subCheck" v-model="t_expendbill.EXPENDBILL_NAME" h-placeholder="经费名称"></first-input-box>
        </dd>
        <dd class="form-list">
          <fourth-input-box h-kind="1" :h-check="subCheck" :h-value="t_expendbill.EXPENDBILL_DATE" h-placeholder="申请日期" h-date="date" @changeInput="(time)=>{
          t_expendbill.EXPENDBILL_DATE = time
          }"></fourth-input-box>
        </dd>
        <dd class="form-list">
          <first-input-box h-kind="1" :h-check="subCheck" v-model="t_expendbill.APPLICAION_SITE" h-placeholder="申请地点"></first-input-box>
        </dd>
        <dd class="form-list">
          <first-input-box h-kind="1" :h-check="subCheck" v-model="t_expendbill.EXPENDITURE_EXPLAIN" h-placeholder="经费说明"></first-input-box>
        </dd>
          </dl>
          <!-- <div class="form-card form-card-top" v-for="(item,index) in t_expensedetail" :key="index">
            <div class="project-container">
            <h5 class="title">业务详情</h5>
            <dl class="project-content" style="position:static" :class="{'transtion-project': false}">
              <dd class="form-list">
                <first-input-box h-kind="1" :h-check="subCheck" v-model="item.EXPENSE_ITEM" h-placeholder="其它明细"></first-input-box>
              </dd>
              <dt v-if="t_expensedetail.length > 1" class="reduce" @click="reduceColumn(index)">删除项目</dt>
            </dl>
            </div>
          </div>
          <div class="form-card form-card-top">
            <div class="add" @click="addColumn"><span class="financial-reimbursement-plus financial-reimbursement-iconfont"></span>新增</div>
            <dl class="statistics">
              <dd class="form-list">
                <first-input-box h-kind="2" :h-check="subCheck" v-model="t_expendbill.PAYMENT_LOWER" h-type="number" h-placeholder="合计金额"></first-input-box>
              </dd>
              <dd class="form-list">
                <second-input-box name="大写金额" :content="t_expendbill.PAYMENT_CAP"></second-input-box>
              </dd>
            </dl>
          </div> -->
          <input type="text" style="position:fixed;top:-100rem;left:-100rem;z-index:-1" @focus="$event.currentTarget.blur()">
        </div>
      </swiper-slide>
      <swiper-slide :class="{'swiper-no-swiping': $store.state.overHidden}">
        <div class="form-container" :class="$store.state.overHidden ? 'over-hidden' : ''">
          <!-- <div>
          <dl class="form-card" v-for="(item3, index3) in t_expensedetail2" :key="index3">
          <dd class="form-list">
            <my-component v-model="item3.EXPENSE_ITEM"></my-component>
          </dd>
      </dl>
      </div> -->
      <div @click="adda">添加</div>
        <div>
          <dl class="form-card" v-for="(item,index) in t_expensedetail" :key="index" :class="{'form-card-top': index !== 0}">
            <dt v-if="index === 0" class="step-content">第三步：填写经费详情</dt>
            <dd class="reduce-container" v-if="t_expensedetail.length > 1">
              <div>其它明细（{{index+1}}）</div>
              <div class="reduce" @click="reduceColumn(index)">删除</div>
            </dd>
            <dd class="form-list">
            <!-- <my-component v-model="item.EXPENSE_ITEM"></my-component> -->
              <!-- <input type="text" style="height:50px" v-model="t_expensedetail[index].EXPENSE_ITEM"> -->
            <first-input-box h-kind="1" :h-check="subCheck" v-model="t_expensedetail[index].EXPENSE_ITEM" h-placeholder="其它明细"></first-input-box>
            <!-- <first-input-box  v-model="item.EXPENSE_ITEM"></first-input-box> -->
          </dd>
         <dd v-if="t_expensedetail.length-1 === index" class="add" @click="addColumn"><span class="financial-reimbursement-plus financial-reimbursement-iconfont"></span>新增</dd>
          </dl>
          </div>
         <!-- <div class="add" @click="addColumn"><span class="financial-reimbursement-plus financial-reimbursement-iconfont"></span>新增</div> -->
          <input type="text" style="position:fixed;top:-100rem;left:-100rem;z-index:-1" @focus="$event.currentTarget.blur()">
        </div>
      </swiper-slide>
      <swiper-slide :class="{'swiper-no-swiping': $store.state.overHidden}">
        <div class="form-container">
          <div class="form-card">
            <div class="step-content">第五步：上传相关附件</div>
              <div class="form-list">
                <first-input-box h-kind="2" :h-check="subCheck" v-model="t_expendbill.PAYMENT_LOWER" h-type="number" h-placeholder="合计金额"></first-input-box>
              </div>
              <div class="form-list">
                <second-input-box name="大写金额" :content="t_expendbill.PAYMENT_CAP"></second-input-box>
              </div>
            <upload-file @imgArr="imgArr" :http-img-arr="ImageBase64Arr"></upload-file>
          </div>
          <div class="form-submit">
            <div class="btn-container" v-if="chose_btn">
              <button class="btn" @click="sumitFunc('1000')">保存</button>
            </div>
            <div class="btn-container-column" v-if="!chose_btn">
              <button class="btn" @click="sumitFunc('1000')">保存</button>
              <button class="btn" @click="sumitFunc('9999')">删除</button>
              <button class="btn" @click="submitPoput(true)">提交</button>
            </div>
          </div>
          <!-- <div class="banner-show">
            <img src="../../../assets/img/banner-02.jpg" alt="">
          </div> -->
        </div>
      </swiper-slide>
      <!-- Optional controls -->
      <!-- <div class="swiper-pagination" :style="{'z-index': $store.state.zIndex}" slot="pagination"></div> -->
      <!-- <div class="swiper-button-prev" slot="button-prev"></div>
    <div class="swiper-button-next" slot="button-next"></div>
    <div class="swiper-scrollbar"   slot="scrollbar"></div> -->
    </swiper>
    <ol class="pagination-container" :style="{'z-index': $store.state.zIndex}">
      <li class="pagination-dot" v-for="(item, index) in isTrue" :key="index">
        <span class="pagination-num" @click="slideToFunc(index)" :class="{'pagination-num-active':activeIndex>=index}">{{index+1}}</span>
        <span class="pagination-progress" :class="{'pagination-progress-active':activeIndex>=index}" v-if="isTrue.length-1 >index"></span>
        <div class="pagination-finished" v-show="item">
          <img src="../../../assets/img/icon-02.png"/>
        </div>
      </li>
    </ol>
    <div class="chose-popup" v-if="submit_popup">
      <chose-alert @closeShade="submitPoput(false)" :type="1" @submitForm="submitForm" :info="{FINANCEPROINST_ID: FINANCEPROINST_ID, OPERATION_TYPE: OPERATION_TYPE}"></chose-alert>
    </div>
  </div>
</template>

<script>
import checkBox from '../../assembly/checkBox'
import firstInputBox from '../../assembly/firstInputBox'
import sevenInputBox from '../../assembly/sevenInputBox'
import myComponent from '../../assembly/myComponent'
import secondInputBox from '../../assembly/secondInputBox'
import thirdInputBox from '../../assembly/thirdInputBox'
import fourthInputBox from '../../assembly/fourthInputBox'
import uploadFile from '../../assembly/uploadFile'
import choseAlert from '../../mode/choseAlert'
import myClass from '@/assets/js/common'
import { Toast, Indicator, MessageBox } from 'mint-ui'
export default {
  name: 'expenseReimbursement',

  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination',
          clickable: true,
          // renderBullet: function (index, className) {
          //   return `<div class="${className}">
          //   <span class="bar-pagination"></span>
          //   <span class="financial-reimbursement-wancheng1 financial-reimbursement-iconfont finish-tick"></span>
          //   <span class="step-text">${index === 0 ? '① 填写业务名称': index === 1 ? '② 填写业务基本信息' : '③ 提交审核意见'}</span>
          //   </div>`
          // }
        },
        noSwipin: true // true 不能拖动轮播配合类swiper-no-swiping
        // slidesPerView: 'auto', // 可以自适应
        // centeredSlides: true, // 轮播图居中
        // spaceBetween: 5, // 空5
        // slideToClickedSlide: true // 点击slide可以轮播
      }, // 轮播配置
      activeIndex: 0, // 当前轮播位置
      swpierPosition: [false, false, false, false], // 轮播图的长度及完成的swiper

      submit_popup: false, // 提交 转交展示 false隐藏
      chose_btn: true, // 提交显示
      subCheck: 0, // 是否校验
      FINANCEPROINST_ID: '', // 项目内码
      OPERATION_TYPE: '', // 业务类型 同ACCEPT_TYPE
      ImageBase64:'', // 附件图片
      ImageBase64Arr: [], // base64图片
      NOWACTDEF_IDS: '', // 当前环节内码
      t_financeproinst: {
        FINANCEPROINST_ID: '', // 项目内码
        PRODEF_ID: '', // 流程内码
        ACCEPT_TYPE: '', // 业务类型
        ACCEPT_NAME: '', // 业务名称
        STAFF_NAME: '', // 申请人员
        FINANCEPROINST_NEXTID: '', // 业务状态
        FINANCEPROINST_DESC: '', // 备注
        FINANCEPROINST_CREATEDATE: '' // 时间
      },
      t_expendbill: {
        EXPENDBILL_ID: '', // 内码
        FINANCEPROINST_ID: '', // 业务内码
        EXPENDBILL_TYPE: '', // 入账类型 1000 公务卡 2000 工资卡
        DEPARTMENT_NAME: '', // 报销部门
        EXPENDBILL_DATE: myClass.computedDateTime().split(' ')[0], // 报销日期
        BUSINESS_PERSON: '', // 出差人
        BUSINESS_REASON: '', // 出差事由
        EXPENDBILL_NAME: '', // 项目名称
        PAYMENT_LOWER: '', // 合计金额（小写）
        PAYMENT_CAP: '', // 合计金额（大写）
        CONTRACT_CODE: '', // 合同编号
        FUNDS_USE: '', // 资金用途
        CONTRACT_TOTALAMOUNT: '', // 合同总金额
        PAY_BASIS: '', // 支付依据
        PERPAID_TOTALAMOUNT: '', // 前期累计支付金额
        INBUDGET: '', // 是否为预算内项目
        BUDGET_AMOUNT: '', // 年初预算金额
        BUDGET_NAME: '', // 年初预算项目名称
        ELECTRONIC_INVOICE: '', // 是否使用电子发票 0 不使用 1使用
        BILLCODE: '', // 电子发票号码
        PAYEE: '', // 收款单位
        PAYEE_ACCOUNT: '', // 收款账户
        APPLICAION_SITE: '', // 申请地点
        EXPENDITURE_EXPLAIN: '', // 经费使用说明
        PROPERTY_PRICE: '', // 资产原值
        DEPRECIATION_PRICE: '', // 累计折旧
        FIXEDASSETS_PRICE: '', // 固定资产净值
        BUY_DATE: '', // 购置日期
        BUY_AMOUNT: '', // 购置数量
        EXPENDBILL_DESC: '' // 备注
      },
      t_expensedetail: [{
        EXPENSEDETAIL_ID: '', // 内码
        EXPENSEBILL_ID: '', // 费用报销内码
        START_DATE: '', // 出发时间
        START_PLACE: '', // 出发地点
        ARRIVE_DATE: '', // 到达时间
        ARRIVE_PLACE: '', // 到达地点
        VEHICLE_TYPE: '', // 交通工具
        BILL_COUNT: '', // 单据张数
        BILL_AMOUNT: '', // 金额
        SUBSIDY_POPULATION: '', // 补贴人数
        SUBSIDY_DAY: '', // 补贴天数
        URBAN_TRAFFIC_ALLOWANCE: '', // 补贴标准
        SUBSIDY_AMOUNT: '', // 补贴金额
        OTHER_COST: '', // 其他费用
        OTHERBILL_COUNT: '', // 其它的单据张数
        OTHERBILL_AMOUNT: '', // 其它的单据金额
        EXPENSE_DETAIL: '', // 项目报销内容
        EXPENSEDETAIL_COUNT: '', // 项目单据张数
        EXPENSEDETAIL_AMOUNT: '', // 项目单据金额
        EXPENSE_ITEM: '', // 费用项目
        EXPENSEDETAIL_DESC: '', // 项目备注
        EXPENSEDETAIL_DATE: '',
        TRAFFIC_EXPENSE: '',
        HOTEL_EXPENSE: ''
      }],
      t_expensedetail2: [{
        EXPENSEDETAIL_ID: '', // 内码
        EXPENSEBILL_ID: '', // 费用报销内码
        START_DATE: '', // 出发时间
        START_PLACE: '', // 出发地点
        ARRIVE_DATE: '', // 到达时间
        ARRIVE_PLACE: '', // 到达地点
        VEHICLE_TYPE: '', // 交通工具
        BILL_COUNT: '', // 单据张数
        BILL_AMOUNT: '', // 金额
        SUBSIDY_POPULATION: '', // 补贴人数
        SUBSIDY_DAY: '', // 补贴天数
        URBAN_TRAFFIC_ALLOWANCE: '', // 补贴标准
        SUBSIDY_AMOUNT: '', // 补贴金额
        OTHER_COST: '', // 其他费用
        OTHERBILL_COUNT: '', // 其它的单据张数
        OTHERBILL_AMOUNT: '', // 其它的单据金额
        EXPENSE_DETAIL: '', // 项目报销内容
        EXPENSEDETAIL_COUNT: '', // 项目单据张数
        EXPENSEDETAIL_AMOUNT: '', // 项目单据金额
        EXPENSE_ITEM: '', // 费用项目
        EXPENSEDETAIL_DESC: '', // 项目备注
        EXPENSEDETAIL_DATE: '',
        TRAFFIC_EXPENSE: '',
        HOTEL_EXPENSE: ''
      }],
    }
  },
  computed: {
    isEmpty () {
      let [T_F, T_E, T_E_D] = [this.t_financeproinst, this.t_expendbill, this.t_expensedetail]
      if (T_F.ACCEPT_NAME === '') {
        return '业务名称不能为空'
      }
      if (T_E.EXPENDBILL_NAME === '') {
        return '经费名称不能为空'
      }
      if (T_E.APPLICAION_SITE === '') {
        return '申请地点不能为空'
      }
      if (T_E.EXPENDITURE_EXPLAIN === '') {
        return '经费说明不能为空'
      }
      for (let i = 0; i < T_E_D.length; ++i) {
        if (T_E_D[i].EXPENSE_ITEM === '') {
          return '其它明细不能为空'
        }
      }
      if (!myClass.provingFloatTwo(T_E.PAYMENT_LOWER)) {
        return '合计金额格式不正确'
      }
      return ''
    },
    isFirst () {
      let [T_F, T_E, T_E_D] = [this.t_financeproinst, this.t_expendbill, this.t_expensedetail]
      if (T_F.ACCEPT_NAME === '' || T_F.FINANCEPROINST_DESC === '') {
        return false
      }
      return true
    },
    isSecond () {
      let [T_F, T_E, T_E_D] = [this.t_financeproinst, this.t_expendbill, this.t_expensedetail]
      if (T_E.EXPENDBILL_NAME === '' ||
          T_E.APPLICAION_SITE === '' ||
          T_E.EXPENDITURE_EXPLAIN === ''
      ) {
        return false
      }
      return true
    },
    isThird () {
      let [T_F, T_E, T_E_D] = [this.t_financeproinst, this.t_expendbill, this.t_expensedetail]
      for (let i = 0; i < T_E_D.length; ++i) {
        if (T_E_D[i].EXPENSE_ITEM === '') {
          return false
        }
      }
      return true
    },
    // 人民币统计小写
    lowerFourth () { 
     return this.t_expendbill.PAYMENT_LOWER
    },
    isTrue () {
       let [T_F, T_E, T_E_D] = [this.t_financeproinst, this.t_expendbill, this.t_expensedetail]
      if (T_F.ACCEPT_NAME === '') {
        this.swpierPosition[0] = false
      } else {
        this.swpierPosition[0] = true
      }

      if(T_E.EXPENDBILL_NAME === '' ||
        T_E.APPLICAION_SITE === '' ||
        T_E.EXPENDITURE_EXPLAIN === ''
      ){
        this.swpierPosition[1] = false
      }else{
        this.swpierPosition[1] = true
      }

      for (let i = 0; i < T_E_D.length; ++i) {
        if (T_E_D[i].EXPENSE_ITEM === '') {
          this.swpierPosition[2] = false
          break
        } else {
          this.swpierPosition[2] = true
        }
      }
      if (!myClass.provingFloatTwo(T_E.PAYMENT_LOWER)) {
        this.swpierPosition[3] = false
      } else {
        this.swpierPosition[3] = true
      }
      return this.swpierPosition
  }
  },
  watch: {
    lowerFourth (afterData, beforeData) {
      this.t_expendbill.PAYMENT_CAP = myClass.convertCurrency(afterData)
    }
  },
  components: {
    firstInputBox,
    secondInputBox,
    thirdInputBox,
    fourthInputBox,
    checkBox,
    sevenInputBox,
    uploadFile,
    choseAlert,
    myComponent
  },

  methods: {
    adda () {
      this.t_expensedetail2.push({
        EXPENSEDETAIL_ID: '', // 内码
        EXPENSEBILL_ID: '', // 费用报销内码
        START_DATE: '', // 出发时间
        START_PLACE: '', // 出发地点
        ARRIVE_DATE: '', // 到达时间
        ARRIVE_PLACE: '', // 到达地点
        VEHICLE_TYPE: '', // 交通工具
        BILL_COUNT: '', // 单据张数
        BILL_AMOUNT: '', // 金额
        SUBSIDY_POPULATION: '', // 补贴人数
        SUBSIDY_DAY: '', // 补贴天数
        URBAN_TRAFFIC_ALLOWANCE: '', // 补贴标准
        SUBSIDY_AMOUNT: '', // 补贴金额
        OTHER_COST: '', // 其他费用
        OTHERBILL_COUNT: '', // 其它的单据张数
        OTHERBILL_AMOUNT: '', // 其它的单据金额
        EXPENSE_DETAIL: '', // 项目报销内容
        EXPENSEDETAIL_COUNT: '', // 项目单据张数
        EXPENSEDETAIL_AMOUNT: '', // 项目单据金额
        EXPENSE_ITEM: '', // 费用项目
        EXPENSEDETAIL_DESC: '', // 项目备注
        EXPENSEDETAIL_DATE: '',
        TRAFFIC_EXPENSE: '',
        HOTEL_EXPENSE: ''
      })
    },
    shuruFunc (obj,i) {
      this.t_expensedetail[i].EXPENSE_ITEM = obj
    },
    // 滚动到某个块
    slideToFunc (index) {
      this.$refs['mySwiper'].swiper.slideTo(index, 1000, false)
      this.activeIndex = index
    },
    // 轮播结束时候触发
    swiperChangeFunc (e) {
      this.activeIndex = e.swiper.activeIndex
    },
    submitPoput (boo) {
      if(boo) {
      this.$store.commit('mutateChangeZIndex',{overHidden: true, zIndex: -1})
      } else {
        this.$store.commit('mutateChangeZIndex',{overHidden: false, zIndex: 10})
      }
      this.submit_popup = boo
    },
    // 删除栏目
    reduceColumn (index) {
      MessageBox({
  message: `确定要删除项目明细${index + 1}`,
  showCancelButton: true,
  showCancelButton: true,
  confirmButtonText: '确定',
  cancelButtonText: '取消'
}).then(action => (action === 'confirm' ? this.t_expensedetail.splice(index, 1) : null))
    },
    // 添加类目
    addColumn () {
      this.t_expensedetail.push({
        EXPENSEDETAIL_ID: '', // 内码
        EXPENSEBILL_ID: '', // 费用报销内码
        START_DATE: '', // 出发时间
        START_PLACE: '', // 出发地点
        ARRIVE_DATE: '', // 到达时间
        ARRIVE_PLACE: '', // 到达地点
        VEHICLE_TYPE: '', // 交通工具
        BILL_COUNT: '', // 单据张数
        BILL_AMOUNT: '', // 金额
        SUBSIDY_POPULATION: '', // 补贴人数
        SUBSIDY_DAY: '', // 补贴天数
        URBAN_TRAFFIC_ALLOWANCE: '', // 补贴标准
        SUBSIDY_AMOUNT: '', // 补贴金额
        OTHER_COST: '', // 其他费用
        OTHERBILL_COUNT: '', // 其它的单据张数
        OTHERBILL_AMOUNT: '', // 其它的单据金额
        EXPENSE_DETAIL: '', // 项目报销内容
        EXPENSEDETAIL_COUNT: '', // 项目单据张数
        EXPENSEDETAIL_AMOUNT: '', // 项目单据金额
        EXPENSE_ITEM: '', // 费用项目
        EXPENSEDETAIL_DESC: '', // 项目备注
        EXPENSEDETAIL_DATE: '',
        TRAFFIC_EXPENSE: '',
        HOTEL_EXPENSE: ''
      })
    },
    // 添加修改附件图片
    imgArr (obj) {
      this.ImageBase64 = obj
    },
    // 提交审批
    submitForm (obj) {
      if (obj.next.ActDef_ID === undefined || obj.trans.USER_ID === undefined) {
        Toast('业务转出或指定经办人未选')
        return
      }
      if (this.isEmpty !== '') {
        this.subCheck++
        Toast(this.isEmpty)
        return
      }
      Indicator.open({
        text: '数据保存修改中……',
        spinnerType: 'fading-circle'
      })
      this.t_financeproinst.FINANCEPROINST_NEXTID = '1000'
      this.$api.post(this.$apiPath.baseURL, this.$apiPath.url,{
        FINANCEPROINST_ID: this.FINANCEPROINST_ID,
        action_type: 'SubmitFinaceInfo',
        action_data: this.$store.state.openid,
        OPERATION_TYPE: this.OPERATION_TYPE, // 业务类型
        FINANCEPROINST_NEXTID: this.t_financeproinst.FINANCEPROINST_NEXTID, // 业务状态
        ImageBase64: this.ImageBase64, // 附件图片
        t_financeproinst: JSON.stringify([this.t_financeproinst]),
        t_expendbill: JSON.stringify([this.t_expendbill]),
        t_expensedetail: JSON.stringify(this.t_expensedetail)
      }).then(res => {
        Indicator.close()
        if (res.data.ResultObject !== undefined && res.data.ResultObject.length > 0) {
          let resultObject = res.data.ResultObject[0]
          if (resultObject.ResultCode === '100') {
            // Toast({
            //   message: resultObject.ResultDesc,
            //   iconClass: 'icon icon-success'
            // })
            // 流程内码
            this.NOWACTDEF_IDS = resultObject.FourthParameter
            this.FINANCEPROINST_ID = resultObject.FirstParameter
            // 赋值给地址栏 防止刷新数据丢失
            this.t_financeproinst.FINANCEPROINST_ID = resultObject.FirstParameter
            this.FINANCEPROINST_NEXTID = resultObject.FirstParameter
            let query = this.t_financeproinst
            query.ACCEPT_TYPE = resultObject.SecondParameter
            query.OPERATION_TYPE = resultObject.SecondParameter
              this.getDataFunc(resultObject.FirstParameter, resultObject.SecondParameter, resultObject.ThirdParamete, true)
              this.chose_btn = false
              
            // 提交审批
            Indicator.open({
              text: '数据提交中……',
              spinnerType: 'fading-circle'
            })
            this.$api.post(this.$apiPath.baseURL, this.$apiPath.url, {
              action_type: 'SubmitFinaceInfo',
              action_data: this.$store.state.openid, // openid
              FINANCEPROINST_ID: this.FINANCEPROINST_ID, // 项目内码
              OPERATION_TYPE: this.OPERATION_TYPE, // 业务类型
              FINANCEPROINST_NEXTID: 2000, // 业务状态
              APPROVED_INFO: '', // 意见内容
              NextACTDEF_IDS: obj.next.ActDef_ID, // 转出环节内码
              NextSTAFF_ID: obj.trans.USER_ID, // 人员内码
              NOWACTDEF_IDS: this.NOWACTDEF_IDS // 当前环节内码
            }).then(res => {
              Indicator.close()
              if(res.data.ResultObject && res.data.ResultObject.length > 0) {
                if (res.data.ResultObject[0].ResultCode === '100') {
                  Toast(res.data.ResultObject[0].ResultDesc)
                  setTimeout(() => {
                       this.$store.commit('mutateChangeZIndex',{overHidden: false, zIndex: 10})
                    this.$router.push('/Homepage/expenses')
                  }, 2000);
                } else {
                  Toast(res.data.ResultObject[0].ResultDesc)
                }
              }
            }).catch(err => {
            Indicator.close()
              Toast({
              message: `budget提交审批接口出问题啦，${err}`,
              iconClass: 'icon icon-success'
            })
            })
          }
          else {
            Toast({
              message: resultObject.ResultDesc,
              iconClass: 'icon icon-success'
            })
          }
        }
      }).catch(err => {
        Indicator.close()
        Toast({
              message: `budget保存接口出问题啦，${err}`,
              iconClass: 'icon icon-success'
            })
      })

      
    },
    // 获取数据详情（用来修改保存的数据）
    getDataFunc (FINANCEPROINST_ID, OPERATION_TYPE, FINANCEPROINST_NEXTID, loading) {
      if(loading === undefined) {
        Indicator.open({
          text: '数据加载中……',
          spinnerType: 'fading-circle'
        })
      }
      this.$api.post(this.$apiPath.baseURL, this.$apiPath.url, {
        action_type: 'GetExpenseDetail',
        FINANCEPROINST_ID, // 项目内码
        OPERATION_TYPE, // 业务类型
        action_data: this.$store.state.openid, // openid
        FINANCEPROINST_NEXTID // 业务状态
      }).then(res => {
        Indicator.close()
        // 表格数据
        if (res.data.ExpenseBill && res.data.ExpenseBill.length > 0) {
          this.t_expendbill = res.data.ExpenseBill[0]
          this.t_expendbill.EXPENDBILL_DATE = this.t_expendbill.EXPENDBILL_DATE.split(' ')[0]
        }
        // 图片数据
        if (!loading && res.data.ImageList && res.data.ImageList.length > 0) {
          let arr = res.data.ImageList.map(v => {
            return v.IMAGE_URL.replace(/-/g,'/')
          })
          this.ImageBase64Arr = []
          arr.forEach(v => {
            myClass.getBase64(v).then(res => {
              this.ImageBase64Arr.push(res)
            })
          })
        }
        // 其它
        if (res.data.FinanceProinstList && res.data.FinanceProinstList.length > 0) {
          this.NOWACTDEF_IDS = res.data.FinanceProinstList[0].NOWACTDEF_IDS
        }
        // 
        if (res.data.ExpenseDetail && res.data.ExpenseDetail.length > 0) {
          this.t_expensedetail = res.data.ExpenseDetail
        }
      })
    },
    /**
     * 保存 修改 删除 
     * @param state 状态 1000 保存修改 9999 删除 
     */
    sumitFunc (state) {
      if (state === '1000' && this.isEmpty !== '') {
        this.subCheck++
        Toast(this.isEmpty)
        return
      }
      Indicator.open({
        text: state === '1000' ? '数据保存修改中……' : '数据删除中',
        spinnerType: 'fading-circle'
      })
      this.t_financeproinst.FINANCEPROINST_NEXTID = state
      this.$api.post(this.$apiPath.baseURL, this.$apiPath.url,{
        FINANCEPROINST_ID: this.FINANCEPROINST_ID,
        action_type: 'SubmitFinaceInfo',
        action_data: this.$store.state.openid,
        OPERATION_TYPE: this.OPERATION_TYPE, // 业务类型
        FINANCEPROINST_NEXTID: this.t_financeproinst.FINANCEPROINST_NEXTID, // 业务状态
        ImageBase64: this.ImageBase64, // 附件图片
        t_financeproinst: JSON.stringify([this.t_financeproinst]),
        t_expendbill: JSON.stringify([this.t_expendbill]),
        t_expensedetail: JSON.stringify(this.t_expensedetail)
      }).then(res => {
        Indicator.close()
        if (res.data.ResultObject !== undefined && res.data.ResultObject.length > 0) {
          let resultObject = res.data.ResultObject[0]
          if (resultObject.ResultCode === '100') {
            Toast({
              message: resultObject.ResultDesc,
              iconClass: 'icon icon-success'
            })
            // 流程内码
            this.NOWACTDEF_IDS = resultObject.FourthParameter
            this.FINANCEPROINST_ID = resultObject.FirstParameter
            // 赋值给地址栏 防止刷新数据丢失
            this.t_financeproinst.FINANCEPROINST_ID = resultObject.FirstParameter
            this.FINANCEPROINST_NEXTID = resultObject.FirstParameter
            let query = this.t_financeproinst
            query.ACCEPT_TYPE = resultObject.SecondParameter
            query.OPERATION_TYPE = resultObject.SecondParameter
            // 删除完之后  跳转到报销审核列表
            if (state.toString() === '9999') {
              setTimeout(() => {
                this.$router.push('/Homepage/expenses')
              }, 2000)
            } else if (state.toString() === '1000') {
              // 保存或者修改之后地址栏赋值
             // this.$router.push({path: '/tableParent/bookTransfer', query})
              this.getDataFunc(resultObject.FirstParameter, resultObject.SecondParameter, resultObject.ThirdParamete, true)
              this.chose_btn = false
            }
          }
          else {
            Toast({
              message: resultObject.ResultDesc,
              iconClass: 'icon icon-success'
            })
          }
        }
      })
    },
    // 监听失去焦点当前模块是否填充完整
    blurSlideToFunc () {
      if (this.activeIndex === 0 && this.isFirst) {
          this.$refs['mySwiper'].swiper.slideTo(1, 500, false)
          this.activeIndex = 1
      }
      if (this.activeIndex === 1 && this.isSecond) {
          this.$refs['mySwiper'].swiper.slideTo(2, 500, false)
          this.activeIndex = 2
      }
      // if (this.activeIndex === 2 && this.isThird) {
      //     this.$refs['mySwiper'].swiper.slideTo(3, 500, false)
      //     this.activeIndex = 3
      // }
      if (this.activeIndex === 3 && this.isForth) {
          this.$refs['mySwiper'].swiper.slideTo(4, 500, false)
          this.activeIndex = 4
      }
    }
  },
  created () {
    if (this.$store.state.useName !== undefined) {
      this.t_financeproinst.STAFF_NAME = this.$store.state.useName
    }
    let query = this.$route.query
    let [FINANCEPROINST_ID, OPERATION_TYPE, FINANCEPROINST_NEXTID, PRODEF_ID, ACCEPT_TYPE, ACCEPT_NAME, FINANCEPROINST_DESC, FINANCEPROINST_CREATEDATE] = [
          query['FINANCEPROINST_ID'], // 项目内码
          query['OPERATION_TYPE'], // 业务类型
          query['FINANCEPROINST_NEXTID'], // 业务状态
          query['PRODEF_ID'], // 流程内码
          query['ACCEPT_TYPE'], // 业务类型
          query['ACCEPT_NAME'], // 业务名称
          query['FINANCEPROINST_DESC'], // 备注
          query['FINANCEPROINST_CREATEDATE'] // 时间
        ]
    if (FINANCEPROINST_ID && OPERATION_TYPE && FINANCEPROINST_NEXTID) {
      this.chose_btn = false
      this.t_financeproinst.FINANCEPROINST_ID = FINANCEPROINST_ID
      this.FINANCEPROINST_ID = FINANCEPROINST_ID
      this.OPERATION_TYPE = OPERATION_TYPE
      this.t_financeproinst.FINANCEPROINST_NEXTID = FINANCEPROINST_NEXTID
      this.getDataFunc(FINANCEPROINST_ID, OPERATION_TYPE, FINANCEPROINST_NEXTID)
      
    }
    let STAFF_NAME = this.t_financeproinst.STAFF_NAME
    if (PRODEF_ID && ACCEPT_TYPE && FINANCEPROINST_NEXTID && OPERATION_TYPE) {
      this.OPERATION_TYPE = OPERATION_TYPE
      this.t_financeproinst = {
        FINANCEPROINST_ID: FINANCEPROINST_ID || '', // 业务内码
        PRODEF_ID, // 流程内码
        ACCEPT_TYPE, // 业务类型
        STAFF_NAME,
        ACCEPT_NAME: ACCEPT_NAME || '', // 业务名称
        FINANCEPROINST_NEXTID, // 业务状态
        FINANCEPROINST_DESC: FINANCEPROINST_DESC || '', // 备注
        FINANCEPROINST_CREATEDATE: FINANCEPROINST_CREATEDATE || myClass.computedDateTime() // 时间
      }
    }
  },
  mounted () {
    let dom = document.querySelector('.budget')
   let domChildrenInput = dom.querySelectorAll('input')
   let domChildrenTextarea = dom.querySelectorAll('textarea')
  for (let i = 0; i < domChildrenInput.length; ++i) {
    domChildrenInput[i].onblur = this.blurSlideToFunc.bind(this)
    // domChildrenInput[i].onfocus = this.focusSlideToFunc.bind(this)
  }
  for (let i = 0; i < domChildrenTextarea.length; ++i) {
    domChildrenTextarea[i].onblur = this.blurSlideToFunc.bind(this)
    // domChildrenInput[i].onfocus = this.focusSlideToFunc.bind(this)
  }
  }
}
</script>
<style lang="stylus" scoped>
$rem = 2.5
.main
  .form-container
    .statistics
      width 100%
    .add
      display flex
      flex-flow row nowrap
      justify-content center
      align-items center
      width 100%
      height 0.8rem * $rem
      font-weight 400
      font-size 0.32rem * $rem
      text-align center
      margin-top 1px
      color #5094f3
      margin-top 1px
      border-bottom 5px solid #c2e5ff
      border-bottom 0.02rem * $rem solid #dddddd
      background-color #ffffff
      .financial-reimbursement-plus 
        line-height 0.32rem * $rem
        font-size 0.6rem * $rem
      &:active
        background-color #dddddd
    .reduce-container
      display flex
      justify-content space-between
      align-items center
      margin-top 0
      padding 0 0.18rem * $rem
      border-bottom 0.02rem * $rem solid #dddddd
    .reduce
      display flex
      flex-flow row nowrap
      justify-content center
      align-items center
      // width 100%
      height 0.8rem * $rem
      font-weight 400
      font-size 12px
      text-align center
      margin-top 1px
      color #333
.transtion-project
  transition all 0.1s
  height 1.82rem * $rem
</style>


